package com.bh.web.controller.shipment;

import com.bh.common.annotation.Log;
import com.bh.common.core.controller.BaseController;
import com.bh.common.core.domain.AjaxResult;
import com.bh.common.core.page.TableDataInfo;
import com.bh.common.enums.BusinessType;
import com.bh.common.utils.poi.ExcelUtil;
import com.bh.shipment.domain.JcVehicleArrive;
import com.bh.shipment.service.IJcVehicleArriveService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 新车辆到站Controller
 * 
 * @author slx
 * @date 2024-03-09
 */
@RestController
@RequestMapping("/shipment/vehicleArrive")
public class JcVehicleArriveController extends BaseController
{
    @Autowired
    private IJcVehicleArriveService jcVehicleArriveService;

    /**
     * 查询新车辆到站列表
     */
    @ApiOperation("查询新车辆到站列表")
    @PreAuthorize("@ss.hasPermi('shipment:vehicleArrive:list')")
    @GetMapping("/list")
    public TableDataInfo list(JcVehicleArrive jcVehicleArrive)
    {
        startPage();
        List<JcVehicleArrive> list = jcVehicleArriveService.selectJcVehicleArriveList(jcVehicleArrive);
        return getDataTable(list);
    }

    /**
     * 导出新车辆到站列表
     */
    @PreAuthorize("@ss.hasPermi('shipment:vehicleArrive:export')")
    @Log(title = "新车辆到站", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, JcVehicleArrive jcVehicleArrive)
    {
        List<JcVehicleArrive> list = jcVehicleArriveService.selectJcVehicleArriveList(jcVehicleArrive);
        ExcelUtil<JcVehicleArrive> util = new ExcelUtil<JcVehicleArrive>(JcVehicleArrive.class);
        util.exportExcel(response, list, "新车辆到站数据");
    }

    /**
     * 获取新车辆到站详细信息
     */
    @ApiOperation("获取新车辆到站详细信息")
    @PreAuthorize("@ss.hasPermi('shipment:vehicleArrive:query')")
    @GetMapping( "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(jcVehicleArriveService.selectJcVehicleArriveById(id));
    }

    /**
     * 新增新车辆到站
     */
    @ApiOperation("新增新车辆到站")
    @PreAuthorize("@ss.hasPermi('shipment:vehicleArrive:add')")
    @Log(title = "新车辆到站", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody JcVehicleArrive jcVehicleArrive)
    {
        return toAjax(jcVehicleArriveService.insertJcVehicleArrive(jcVehicleArrive));
    }

    /**
     * 修改新车辆到站
     */
    @ApiOperation("修改新车辆到站")
    @PreAuthorize("@ss.hasPermi('shipment:vehicleArrive:edit')")
    @Log(title = "新车辆到站", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody JcVehicleArrive jcVehicleArrive)
    {
        return toAjax(jcVehicleArriveService.updateJcVehicleArrive(jcVehicleArrive));
    }

    /**
     * 删除新车辆到站
     */
    @ApiOperation("删除新车辆到站")
    @PreAuthorize("@ss.hasPermi('shipment:vehicleArrive:remove')")
    @Log(title = "新车辆到站", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(jcVehicleArriveService.deleteJcVehicleArriveByIds(ids));
    }


    /**
     * 车辆到站操作
     * @param jcShipmentIds
     * @return
     */
    @ApiOperation("车辆到站操作")
    @PostMapping("/saveVehicleArrive/{jcShipmentIds}")
    public AjaxResult saveVehicleArrive(@PathVariable Long[] jcShipmentIds) {
        return toAjax(jcVehicleArriveService.saveVehicleArrive(jcShipmentIds));
    }
}
